In [2]:
from miscpy.utils.sympyhelpers import *
init_printing()

In [3]:
mu,rg,I1,I2,I3,n,w1,w2,w3,w1d,w2d,w3d,t = symbols('mu,r_G,I_1,I_2,I_3,n,omega_1,omega_2,omega_3,omegadot_1,omegadot_2,omegadot_3,t')
diffmap = {w1:w1d,w2:w2d,w3:w3d}

In [4]:
bCa = fancyMat('{}^\mathcal{B}C^{\mathcal{A}}',(3,3));bCa


Out[4]:
$$\left[\begin{matrix}{}^\mathcal{B}C^{\mathcal{A}}_{11} & {}^\mathcal{B}C^{\mathcal{A}}_{12} & {}^\mathcal{B}C^{\mathcal{A}}_{13}\\{}^\mathcal{B}C^{\mathcal{A}}_{21} & {}^\mathcal{B}C^{\mathcal{A}}_{22} & {}^\mathcal{B}C^{\mathcal{A}}_{23}\\{}^\mathcal{B}C^{\mathcal{A}}_{31} & {}^\mathcal{B}C^{\mathcal{A}}_{32} & {}^\mathcal{B}C^{\mathcal{A}}_{33}\end{matrix}\right]$$

In [5]:
en_B = bCa*Matrix([0,1,0]); en_B


Out[5]:
$$\left[\begin{matrix}{}^\mathcal{B}C^{\mathcal{A}}_{12}\\{}^\mathcal{B}C^{\mathcal{A}}_{22}\\{}^\mathcal{B}C^{\mathcal{A}}_{32}\end{matrix}\right]$$

In [6]:
Ig_B = diag(I1,I2,I3)

In [7]:
Mg_B = simplify(skew(en_B)*Ig_B*en_B); Mg_B


Out[7]:
$$\left[\begin{matrix}{}^\mathcal{B}C^{\mathcal{A}}_{22} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(- I_{2} + I_{3}\right)\\{}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(I_{1} - I_{3}\right)\\{}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(- I_{1} + I_{2}\right)\end{matrix}\right]$$

In [ ]:

Circular orbit


In [8]:
iWa_A = Matrix([0,0,n]); iWa_A


Out[8]:
$$\left[\begin{matrix}0\\0\\n\end{matrix}\right]$$

In [9]:
iWb_B = Matrix([w1,w2,w3]); iWb_B


Out[9]:
$$\left[\begin{matrix}\omega_{1}\\\omega_{2}\\\omega_{3}\end{matrix}\right]$$

In [10]:
tmp1 = simplify(Ig_B*difftotalmat(iWb_B,t,diffmap) + skew(iWb_B)*Ig_B*iWb_B - 3*n**2*Mg_B);tmp1


Out[10]:
$$\left[\begin{matrix}I_{1} \dot{\omega}_{1} - I_{2} \omega_{2} \omega_{3} + I_{3} \omega_{2} \omega_{3} + 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{22} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(I_{2} - I_{3}\right)\\I_{1} \omega_{1} \omega_{3} + I_{2} \dot{\omega}_{2} - I_{3} \omega_{1} \omega_{3} - 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(I_{1} - I_{3}\right)\\- I_{1} \omega_{1} \omega_{2} + I_{2} \omega_{1} \omega_{2} + I_{3} \dot{\omega}_{3} + 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(I_{1} - I_{2}\right)\end{matrix}\right]$$

In [11]:
simplify(tmp1)


Out[11]:
$$\left[\begin{matrix}I_{1} \dot{\omega}_{1} - I_{2} \omega_{2} \omega_{3} + I_{3} \omega_{2} \omega_{3} + 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{22} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(I_{2} - I_{3}\right)\\I_{1} \omega_{1} \omega_{3} + I_{2} \dot{\omega}_{2} - I_{3} \omega_{1} \omega_{3} - 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(I_{1} - I_{3}\right)\\- I_{1} \omega_{1} \omega_{2} + I_{2} \omega_{1} \omega_{2} + I_{3} \dot{\omega}_{3} + 3 n^{2} {}^\mathcal{B}C^{\mathcal{A}}_{12} {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(I_{1} - I_{2}\right)\end{matrix}\right]$$

In [12]:
aWb_B = iWb_B - bCa*iWa_A; aWb_B


Out[12]:
$$\left[\begin{matrix}- n {}^\mathcal{B}C^{\mathcal{A}}_{13} + \omega_{1}\\- n {}^\mathcal{B}C^{\mathcal{A}}_{23} + \omega_{2}\\- n {}^\mathcal{B}C^{\mathcal{A}}_{33} + \omega_{3}\end{matrix}\right]$$

In [13]:
dbCa = simplify(-skew(aWb_B)*bCa); dbCa


Out[13]:
$$\left[\begin{matrix}- {}^\mathcal{B}C^{\mathcal{A}}_{21} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{31} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right) & - {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right) & - \omega_{2} {}^\mathcal{B}C^{\mathcal{A}}_{33} + \omega_{3} {}^\mathcal{B}C^{\mathcal{A}}_{23}\\{}^\mathcal{B}C^{\mathcal{A}}_{11} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) - {}^\mathcal{B}C^{\mathcal{A}}_{31} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right) & {}^\mathcal{B}C^{\mathcal{A}}_{12} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) - {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right) & \omega_{1} {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3} {}^\mathcal{B}C^{\mathcal{A}}_{13}\\- {}^\mathcal{B}C^{\mathcal{A}}_{11} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{21} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right) & - {}^\mathcal{B}C^{\mathcal{A}}_{12} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right) & - \omega_{1} {}^\mathcal{B}C^{\mathcal{A}}_{23} + \omega_{2} {}^\mathcal{B}C^{\mathcal{A}}_{13}\end{matrix}\right]$$

In [14]:
dbCa[:,1]


Out[14]:
$$\left[\begin{matrix}- {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right)\\{}^\mathcal{B}C^{\mathcal{A}}_{12} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{33} - \omega_{3}\right) - {}^\mathcal{B}C^{\mathcal{A}}_{32} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right)\\- {}^\mathcal{B}C^{\mathcal{A}}_{12} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{23} - \omega_{2}\right) + {}^\mathcal{B}C^{\mathcal{A}}_{22} \left(n {}^\mathcal{B}C^{\mathcal{A}}_{13} - \omega_{1}\right)\end{matrix}\right]$$

In [ ]: